
package com.probiz.estore.common.model.order.base;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.order.SalesOrder;
import com.probiz.estore.common.model.product.ProductSku;
import com.probiz.estore.common.model.sales.Gift;
import com.probiz.estore.common.model.sales.GiftCertificate;
import com.probiz.estore.core.model.BaseObject;

/**
 * OrderSku Base Java Bean, base class for the model, mapped directly to
 * database table
 * 
 * Avoid changing this file if not necessary, will be overwritten.
 * 
 */
public class OrderSkuTbl extends BaseObject implements Serializable {

	protected Integer			orderSkuId;
	/**
	 * 销售项的类型 1=商品 2=礼券 3=礼品
	 */
	protected Short				itemType;
	/**
	 * 商品id
	 */
	protected Integer			productId;
	/**
	 * 商品名称
	 */
	protected String			productName;
	/**
	 * 货品编号
	 */
	protected String			productSkuCode;
	/**
	 * 规格字符串 用于显示skuOption; 格式optionName1:optionValue1;optionName2:optionValue2
	 * 例如:color:red;size:xl
	 */
	protected String			displaySkuOptions;
	/**
	 * 数量
	 */
	protected Integer			quantity;
	/**
	 * 售出价格（单件）
	 */
	protected BigDecimal		price;
	/**
	 * 是否特价产品
	 */
	protected Short				isOnSale;
	/**
	 * 是否批发产品
	 */
	protected Short				isWholesale;
	/**
	 * 税费
	 */
	protected BigDecimal		tax;
	/**
	 * 税名称
	 */
	protected String			taxName;
	/**
	 * 销售项小计 = 单件价格X数量-单项折扣+税费
	 * subtotal = price * quantity - discount+tax 
	 */
	protected BigDecimal		subtotal;
	/**
	 * 单项折扣
	 */
	protected BigDecimal		discount;
	/**
	 * 重量
	 */
	protected BigDecimal		weight;
	/**
	 * 已分配数量
	 */
	protected Integer			allocatedQuantity;
	/**
	 * 已发货数量
	 */
	protected Integer			deliveryQuantity;
	
	/**
	 * 指向订单
	 */
	protected SalesOrder		salesOrder;
	/**
	 * 指向礼券
	 */
	protected GiftCertificate	giftCertificate;
	/**
	 * 指向货品
	 */
	protected ProductSku		productSku;
	/**
	 * 发退货项明细集合
	 */
	protected Set		orderShipmentItems	= new HashSet();
	
	protected Gift gift;
	
	protected Integer			version;

	/**
	 * Default Empty Constructor for class OrderSku
	 */
	public OrderSkuTbl() {
		super();
	}

	/**
	 * Default Key Fields Constructor for class OrderSku
	 */
	public OrderSkuTbl(Integer in_orderSkuId) {
		this.setOrderSkuId(in_orderSkuId);
	}

	public Gift getGift() {
		return gift;
	}

	public void setGift(Gift gift) {
		this.gift = gift;
	}

	public SalesOrder getSalesOrder() {
		return salesOrder;
	}

	public void setSalesOrder(SalesOrder in_salesOrder) {
		this.salesOrder = in_salesOrder;
	}

	public GiftCertificate getGiftCertificate() {
		return giftCertificate;
	}

	public void setGiftCertificate(GiftCertificate in_giftCertificate) {
		this.giftCertificate = in_giftCertificate;
	}

	public ProductSku getProductSku() {
		return productSku;
	}

	public void setProductSku(ProductSku in_productSku) {
		this.productSku = in_productSku;
	}

	public Set getOrderShipmentItems() {
		return orderShipmentItems;
	}

	public void setOrderShipmentItems(Set in_orderShipmentItems) {
		this.orderShipmentItems = in_orderShipmentItems;
	}

	/**
	 * *
	 * 
	 * @return Integer
	 * @hibernate.id column="orderSkuId" type="java.lang.Integer"
	 *               generator-class="native"
	 */
	public Integer getOrderSkuId() {
		return this.orderSkuId;
	}

	/**
	 * Set the orderSkuId
	 */
	public void setOrderSkuId(Integer aValue) {
		this.orderSkuId = aValue;
	}

	/**
	 * 销售项的类型 1=商品 2=礼券 3=礼品
	 * 
	 * @return Short
	 * @hibernate.property column="itemType" type="java.lang.Short" length="5"
	 *                     not-null="true" unique="false"
	 */
	public Short getItemType() {
		return this.itemType;
	}

	/**
	 * Set the itemType
	 * 
	 * @spring.validator type="required"
	 */
	public void setItemType(Short aValue) {
		this.itemType = aValue;
	}

	/**
	 * 销售订单外键 *
	 * 
	 * @return Integer
	 */
	public Integer getSalesOrderId() {
		return this.getSalesOrder() == null ? null : this.getSalesOrder()
				.getSalesOrderId();
	}

	/**
	 * Set the salesOrderId
	 */
	public void setSalesOrderId(Integer aValue) {
		if (aValue == null) {
			salesOrder = null;
		} else {
			salesOrder = new SalesOrder(aValue);
			salesOrder.setVersion(Integer.valueOf(0));// set a version to cheat
													// hibernate only
		}
	}

	/**
	 * 礼券外键 *
	 * 
	 * @return Integer
	 */
	public Integer getGiftCertificateId() {
		return this.getGiftCertificate() == null ? null : this
				.getGiftCertificate().getGiftCertificateId();
	}

	/**
	 * Set the giftCertificateId
	 */
	public void setGiftCertificateId(Integer aValue) {
		if (aValue == null) {
			giftCertificate = null;
		} else {
			giftCertificate = new GiftCertificate(aValue);
			giftCertificate.setVersion(Integer.valueOf(0));// set a version to
														// cheat hibernate only
		}
	}

	/**
	 * 货品id *
	 * 
	 * @return Integer
	 */
	public Integer getProductSkuId() {
		return this.getProductSku() == null ? null : this.getProductSku()
				.getProductSkuId();
	}

	/**
	 * Set the productSkuId
	 */
	public void setProductSkuId(Integer aValue) {
		if (aValue == null) {
			productSku = null;
		} else {
			productSku = new ProductSku(aValue);
			productSku.setVersion(Integer.valueOf(0));// set a version to cheat
													// hibernate only
		}
	}

	/**
	 * 商品id *
	 * 
	 * @return Integer
	 * @hibernate.property column="productId" type="java.lang.Integer"
	 *                     length="10" not-null="false" unique="false"
	 */
	public Integer getProductId() {
		return this.productId;
	}

	/**
	 * Set the productId
	 */
	public void setProductId(Integer aValue) {
		this.productId = aValue;
	}

	/**
	 * 商品名称 *
	 * 
	 * @return String
	 * @hibernate.property column="productName" type="java.lang.String"
	 *                     length="512" not-null="false" unique="false"
	 */
	public String getProductName() {
		return this.productName;
	}

	/**
	 * Set the productName
	 */
	public void setProductName(String aValue) {
		this.productName = aValue;
	}

	/**
	 * 货品编号 *
	 * 
	 * @return String
	 * @hibernate.property column="productSkuCode" type="java.lang.String"
	 *                     length="32" not-null="false" unique="false"
	 */
	public String getProductSkuCode() {
		return this.productSkuCode;
	}

	/**
	 * Set the productSkuCode
	 */
	public void setProductSkuCode(String aValue) {
		this.productSkuCode = aValue;
	}

	/**
	 * 规格字符串 用于显示skuOption; 格式optionName1:optionValue1;optionName2:optionValue2
	 * 例如:color:red;size:xl *
	 * 
	 * @return String
	 * @hibernate.property column="displaySkuOptions" type="java.lang.String"
	 *                     length="255" not-null="false" unique="false"
	 */
	public String getDisplaySkuOptions() {
		return this.displaySkuOptions;
	}

	/**
	 * Set the displaySkuOptions
	 */
	public void setDisplaySkuOptions(String aValue) {
		this.displaySkuOptions = aValue;
	}

	/**
	 * 数量 *
	 * 
	 * @return Integer
	 * @hibernate.property column="quantity" type="java.lang.Integer"
	 *                     length="10" not-null="true" unique="false"
	 */
	public Integer getQuantity() {
		return this.quantity;
	}

	/**
	 * Set the quantity
	 * 
	 * @spring.validator type="required"
	 */
	public void setQuantity(Integer aValue) {
		this.quantity = aValue;
	}

	/**
	 * 售出价格（单件） *
	 * 
	 * @return BigDecimal
	 * @hibernate.property column="price" type="BigDecimal" length="12"
	 *                     not-null="true" unique="false"
	 */
	public BigDecimal getPrice() {
		return this.price;
	}

	/**
	 * Set the price
	 * 
	 * @spring.validator type="required"
	 */
	public void setPrice(BigDecimal aValue) {
		this.price = aValue;
	}

	/**
	 * 是否特价产品 *
	 * 
	 * @return Short
	 * @hibernate.property column="isOnSale" type="java.lang.Short" length="5"
	 *                     not-null="false" unique="false"
	 */
	public Short getIsOnSale() {
		return this.isOnSale;
	}

	/**
	 * Set the isOnSale
	 */
	public void setIsOnSale(Short aValue) {
		this.isOnSale = aValue;
	}

	/**
	 * 是否批发产品 *
	 * 
	 * @return Short
	 * @hibernate.property column="isWholesale" type="java.lang.Short"
	 *                     length="5" not-null="false" unique="false"
	 */
	public Short getIsWholesale() {
		return this.isWholesale;
	}

	/**
	 * Set the isWholesale
	 */
	public void setIsWholesale(Short aValue) {
		this.isWholesale = aValue;
	}

	/**
	 * 税费 *
	 * 
	 * @return BigDecimal
	 * @hibernate.property column="tax" type="BigDecimal" length="12"
	 *                     not-null="false" unique="false"
	 */
	public BigDecimal getTax() {
		return this.tax;
	}

	/**
	 * Set the tax
	 */
	public void setTax(BigDecimal aValue) {
		this.tax = aValue;
	}

	/**
	 * 税名称 *
	 * 
	 * @return String
	 * @hibernate.property column="taxName" type="java.lang.String" length="256"
	 *                     not-null="false" unique="false"
	 */
	public String getTaxName() {
		return this.taxName;
	}

	/**
	 * Set the taxName
	 */
	public void setTaxName(String aValue) {
		this.taxName = aValue;
	}

	/**
	 * 销售项小计 = 单件价格X数量-单项折扣+税费 subtotal = price * quantity - discount+tax *
	 * 
	 * @return BigDecimal
	 * @hibernate.property column="subtotal" type="BigDecimal" length="12"
	 *                     not-null="false" unique="false"
	 */
	public BigDecimal getSubtotal() {
		return this.subtotal;
	}

	/**
	 * Set the subtotal
	 */
	public void setSubtotal(BigDecimal aValue) {
		this.subtotal = aValue;
	}

	/**
	 * 单项折扣 *
	 * 
	 * @return BigDecimal
	 * @hibernate.property column="discount" type="BigDecimal" length="12"
	 *                     not-null="false" unique="false"
	 */
	public BigDecimal getDiscount() {
		return this.discount;
	}

	/**
	 * Set the discount
	 */
	public void setDiscount(BigDecimal aValue) {
		this.discount = aValue;
	}

	/**
	 * 重量 *
	 * 
	 * @return BigDecimal
	 * @hibernate.property column="weight" type="BigDecimal" length="12"
	 *                     not-null="false" unique="false"
	 */
	public BigDecimal getWeight() {
		return this.weight;
	}

	/**
	 * Set the weight
	 */
	public void setWeight(BigDecimal aValue) {
		this.weight = aValue;
	}

	/**
	 * 已分配数量 *
	 * 
	 * @return Integer
	 * @hibernate.property column="allocatedQuantity" type="java.lang.Integer"
	 *                     length="10" not-null="false" unique="false"
	 */
	public Integer getAllocatedQuantity() {
		return this.allocatedQuantity;
	}

	/**
	 * Set the allocatedQuantity
	 */
	public void setAllocatedQuantity(Integer aValue) {
		this.allocatedQuantity = aValue;
	}

	/**
	 * 已发货数量 *
	 * 
	 * @return Integer
	 * @hibernate.property column="deliveryQuantity" type="java.lang.Integer"
	 *                     length="10" not-null="false" unique="false"
	 */
	public Integer getDeliveryQuantity() {
		return this.deliveryQuantity;
	}

	/**
	 * Set the deliveryQuantity
	 */
	public void setDeliveryQuantity(Integer aValue) {
		this.deliveryQuantity = aValue;
	}

	/**
	 * *
	 * 
	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10"
	 *                     not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}

	/**
	 * Set the version
	 * 
	 * @spring.validator type="required"
	 */
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof OrderSkuTbl)) {
			return false;
		}
		OrderSkuTbl rhs = (OrderSkuTbl) object;
		return new EqualsBuilder().append(this.orderSkuId, rhs.orderSkuId)
				.append(this.itemType, rhs.itemType).append(this.productId,
						rhs.productId)
				.append(this.productName, rhs.productName).append(
						this.productSkuCode, rhs.productSkuCode).append(
						this.displaySkuOptions, rhs.displaySkuOptions).append(
						this.quantity, rhs.quantity).append(this.price,
						rhs.price).append(this.isOnSale, rhs.isOnSale).append(
						this.isWholesale, rhs.isWholesale).append(this.tax,
						rhs.tax).append(this.taxName, rhs.taxName).append(
						this.subtotal, rhs.subtotal).append(this.discount,
						rhs.discount).append(this.weight, rhs.weight).append(
						this.allocatedQuantity, rhs.allocatedQuantity).append(
						this.deliveryQuantity, rhs.deliveryQuantity).append(
						this.version, rhs.version).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973).append(
				this.orderSkuId).append(this.itemType).append(this.productId)
				.append(this.productName).append(this.productSkuCode).append(
						this.displaySkuOptions).append(this.quantity).append(
						this.price).append(this.isOnSale).append(
						this.isWholesale).append(this.tax).append(this.taxName)
				.append(this.subtotal).append(this.discount)
				.append(this.weight).append(this.allocatedQuantity).append(
						this.deliveryQuantity).append(this.version)
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("orderSkuId", this.orderSkuId)
				.append("itemType", this.itemType).append("productId",
						this.productId).append("productName", this.productName)
				.append("productSkuCode", this.productSkuCode).append(
						"displaySkuOptions", this.displaySkuOptions).append(
						"quantity", this.quantity).append("price", this.price)
				.append("isOnSale", this.isOnSale).append("isWholesale",
						this.isWholesale).append("tax", this.tax).append(
						"taxName", this.taxName).append("subtotal",
						this.subtotal).append("discount", this.discount)
				.append("weight", this.weight).append("allocatedQuantity",
						this.allocatedQuantity).append("deliveryQuantity",
						this.deliveryQuantity).append("version", this.version)
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "orderSkuId";
	}

	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return orderSkuId;
	}

}